<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<form action="" method="post">
			<input type="button" name="" id="" value="计算两数运算结果" onclick="calculate()" />
			<script type="text/javascript">
				function calculate(){
					var x=parseFloat(prompt("请输入第一个数",""));
					var y=parseFloat(prompt("请输入第二个数",""));
					var operator=prompt("请输入运算符","")
					switch(operator){
						case "+":
						var z=x+y;
						document.write(x+"+"+y+"="+z);
						break;
						case "-":
						var z=x-y;
						document.write(x+"-"+y+"="+z);
						break;
						case "*":
						var z=x*y;
						document.write(x+"*"+y+"="+z);
						break;
						case "/":
						var z=x/y;
						document.write(x+"/"+y+"="+z);
						break;
						default:
						alert("输入错误")
					}
				}
			</script>
			
		</form>
	</body>
</html>
